<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>一点知识系统</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3"/>
<meta http-equiv="description" content="this is my page"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="../../head.js"></script>
<!-- <#include "/jsp/easyui.html"/> -->
<link rel="stylesheet" href="../../kindeditor/themes/default/default.css" />
<link rel="stylesheet" href="../../kindeditor/plugins/code/prettify.css" />

<script charset="utf-8" src="../../kindeditor/kindeditor.js"></script>
<script charset="utf-8" src="../../kindeditor/lang/zh_CN.js"></script>
<script charset="utf-8" src="../../kindeditor/plugins/code/prettify.js"></script>
    
</head>
	<body>
		<form id="my-form">
			<div id="tools" class="datagrid-toolbar">
				<a onclick="save();" class="easyui-linkbutton" iconCls="icon-save" plain="true">保存</a>
				<a onclick="window.location.reload();" class="easyui-linkbutton" iconCls="icon-reload2" plain="true">刷新</a>
				<a onclick="closeWindow();" class="easyui-linkbutton" iconCls="icon-close" plain="true">关闭</a>
		    </div>
			<p id="errorMsg" style="color:red;margin-top:5px;"></p>
			<table class="formTable" >
				<tr>
				<td class="tdc1">
					标题：
				</td>
				<td align="left">
					<input type="text" name="msgtitle" id="msgtitle" class="easyui-validatebox" data-options="required:true" maxlength="100" />
				</td>
				</tr>
				<!-- <tr>
				<td class="tdc1">
					内容：
				</td>
				<td>
					<input type="text" name="msgcontent" data-options="required:true" class="easyui-validatebox" />
				</td>
			   </tr> -->
			   
			   <!-- 文本区 -->
			   <!-- <tr>
				<td class="pn-flabel pn-flabel-h">内容描述:</td>
				<td class="pn-fcontent" colspan="3">
					<textarea id="msgcontent" name="msgcontent" style="width:670px;height:100px;"></textarea>
 	        			<input type="hidden" id="msgcontent" name="msgcontent" value=""/>
       			</td>
			   </tr> -->
			   <!-- 富文本 -->
			    <td class="tdc1">
			  	 简&nbsp;&nbsp;&nbsp;&nbsp;介：
				</td>
				<!-- <td class="pn-flabel pn-flabel-h">简&nbsp;&nbsp;&nbsp;&nbsp;介</td> -->
				<td colspan="4">
					<textarea  id="editor2" name="editor2" rows="5" cols="25" style="width:800px;height:300px;"></textarea>
					<input id="msgcontent" name="msgcontent">
				</td>
			   </tr>
			   <tr>
				<td class="tdc1">
					备注：
				</td>
				<td>
					<textarea id="remark" name="remark"></textarea>
				</td>
			   </tr>
			</table>
		</form>
	</body>
	
	<div>
	 <script id="editor" type="text/plain" style="width:800px;height:400px;"></script>
    </div>
	
    
</html>
<script>
	var editor;
	KindEditor.ready(function(K) {
		editor = K.create('textarea[name="editor2"]', {
			cssPath : 'plugins/code/prettify.css',
			/* uploadFile(); */
			allowFileManager : false
		});
		/* prettyPrint(); */
	});

	var imageurl = "";
	function uploadFile(){
	  $.ajaxFileUpload ({
          url:contextPath+"/system/uploadFile",//用于文件上传的服务器端请求地址
          secureuri: false, //是否需要安全协议，一般设置为false
          fileElementId: "imgFile", //文件上传域的ID
          dataType: 'json', //返回值类型 一般设置为json
          data:{},
          success: function (res){//服务器成功响应处理函数
				if(res['flag'] == "success"){
					$.messager.alert("提示","操作成功!");
					imageurl = res['id'];
					
					prettyPrint();
					
				}else{
					$.messager.alert("提示","操作失败!",'error');
				}
           },
            error: function (data, status, e){//服务器响应失败处理函数
                alert(e);
            }
         });
	}

	function checkFormMe(form){
		return $('#my-form').form('validate');
	}

	window.onload = function(){
		for(i=0;i<=228;i++){
			var icon = "<div onclick=\"checkIcon('icons"+i+"');\" class='icons"+i+"' style='border:1px solid #E0ECFF;width:18px;height:19px;float: left;margin-bottom: 3px;margin-left: 3px;cursor: pointer;'></div>";
			$('#checkIcon').append(icon);
		}
	}
	function checkIcon(ico){
		$('#icon').removeClass();
		$('#icon').addClass(ico);
		$('#img').val(ico);
		$('#checkIcons').dialog('close')
	}
	
	var id = getPram('id');
	$('#parentId').val(id);
	function save(){
		
		var pintroduct = editor.html();
		$("#msgcontent").val(pintroduct);
		var length=$("#msgcontent").val().length;
		if(length <= 00){
			$.messager.alert('提示', '请填写内容信息');
			return;
		}
		
		if(checkFormMe()){
			var arg = $('#my-form').serializeArray();
			jQuery.post(contextPath+"/system/addMessage",arg,
			function (data) {
				var res =$.parseJSON(data.toString());
				if(res['flag'] == "success"){
					$.messager.alert("提示","操作成功!",'info',function(rt){
						window.parent.query();
						closeWindow();
					});
				}else{
					$.messager.alert("提示","操作失败!",'error');
				}
			});
		}
	}
</script>
